package com.woniuxy.repay.service.impl;

import com.woniuxy.entity.RepaymentOverdue;
import com.woniuxy.repay.entity.PageBean;
import com.woniuxy.repay.mapper.RepaymentOverdueMapper;
import com.woniuxy.repay.service.RepaymentOverdueService;
import com.woniuxy.repay.tools.ServiceTool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author shichen
 * @create 2021-11-21-20:36
 * @description
 */
@Slf4j
@Service
public class RepaymentOverdueServiceImpl implements RepaymentOverdueService {

    @Resource
    RepaymentOverdueMapper repaymentOverdueMapper;


    @Override
    public PageBean selectByCondition(RepaymentOverdue repaymentOverdue, Integer pageIndex) {
        List<RepaymentOverdue> repaymentOverdues = repaymentOverdueMapper.selectByCondition(repaymentOverdue);
        // 本来是去调合同表的
        List dataList = ServiceTool.createDataList(repaymentOverdues, pageIndex);
        // repaymentOverdues

        return new PageBean<RepaymentOverdue>(repaymentOverdues.size(), 5, pageIndex, dataList);
    }

    @Override
    public void updateByCondition(RepaymentOverdue repaymentOverdue) {

        if(repaymentOverdue.getId()!=null) {
            repaymentOverdueMapper.updateByCondition(repaymentOverdue);
        }
        // 返回更新后的结果

    }

    @Override
    public void insert(RepaymentOverdue repaymentOverdue) {

        repaymentOverdueMapper.insertByCondition(repaymentOverdue);
    }
}
